package com.clementheliou.cheliou.business.dataaccess.member;

import com.clementheliou.cheliou.business.dataaccess.member.exception.EMailAlreadyUsedException;
import com.clementheliou.cheliou.dal.model.member.Member;

/**
 * Service used to access the members of the model's layer.
 * 
 * @author Clément HELIOU (clement.heliou@gmail.com)
 * @since 1.0
 */
public interface MemberDataAccessService {

	/**
	 * Gets a member by its email. If this last one is not related to an
	 * existing member, <code>null</code> is returned.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param email the email of the member we are looking for.
	 * @return the related member data if it exists, <code>null</code>
	 *         otherwise.
	 * @since 1.0
	 */
	Member getMemberByEMail(String email);

	/**
	 * Updates the given member.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param memberToUpdate the member to be updated.
	 * @since 1.0
	 */
	void updateMember(Member memberToUpdate);

	/**
	 * Persists the given member.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param memberToSave the transient member to be saved.
	 * @throws EMailAlreadyUsedException if the login exists.
	 * @since 1.0
	 */
	void saveMember(Member memberToSave) throws EMailAlreadyUsedException;
}
